package snafu.implementation.actions.create;

import java.util.List;

import snafu.framework.actions.AbstractAction;
import snafu.framework.actions.Intention;
import snafu.framework.objects.WorldObject;
import snafu.framework.objects.WorldObjectItself;
import snafu.framework.states.StateItself;
import snafu.framework.view.Access;
import snafu.framework.worlds.WorldMap;
import snafu.implementation.states.literals.have.HaveLiteralItself;
import snafu.utility.Cast;

public class CreateAction extends AbstractAction {
	public CreateAction(List<WorldObject> targets, Intention<?> intention) {
		super(targets, intention);
	}

	@Override
	public void execute(WorldMap worldMap) {
		// get state
		StateItself agentState = (StateItself) agent.getState();

		// add new object
		WorldObjectItself<?> target = Cast.cast(targets.get(0), WorldObjectItself.class);
		agentState.addLiteral(new HaveLiteralItself(target, Access.PRIVATE));
	}

	@Override
	public String output() {
		return agent + " created " + targets.get(0);
	}

	@Override
	public boolean supportMultiTargets() {
		return false;
	}

}
